package routers

import (
	"sub_account/controllers"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/context"
	"github.com/dchest/captcha"
)

func init() {
	//登录验证码路由
	beego.Handler("/captcha/*.png", captcha.Server(130, 50))

	beego.Include(&controllers.Network{})
	beego.Include(&controllers.LoginAction{})
	beego.Include(&controllers.SysConfigAct{})

	//过滤器
	beego.InsertFilter("/index/*", beego.BeforeRouter, IndexFill)
}

var IndexFill = func(ctx *context.Context) {
	userName := ctx.Input.Session("userName")
	if userName == nil {
		ctx.Redirect(302, "/")
	}
}
